<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>订单提交中心</title>
<script type="text/javascript" src="{{TEMPLATE}}/jquery/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
	//全选商品异步请求地址
	var allCheched = "{{U('MyCart/allCheched')}}";
</script>
<script src="Public/hdjs/hdjs.min.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="Public/hdjs/hdjs.css"/>
<script src="{{TEMPLATE}}/javascript/mycart.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="{{TEMPLATE}}/css/mycart.css" />
<!--异步修改购物车商品当数量里边的值发生改变的时候发送异步-->
<script type="text/javascript">
	$(function(){
		$("input[type='text']").change(function(){
			var shuliang = $(this).val();//商品数量
			var sid = $(this).parents('dd').find('.hiddenSid').val();//商品sid			
			var total = $(this).parents('dd').siblings('.danjia').html();//商品单价
			$(this).parents('dd').siblings('.xiaoji').html(total*shuliang);
			if($(this).parents('dd').siblings('.shopping_cart_tr11').find('input').attr("checked")){
				$.ajax({
					type:"post",
					url:"{{U('MyCart/edit')}}",
					data:{shuliang : shuliang,sid:sid},//请求数据
					dataType:'json',//数据类型
					success:function(phpData){
						$('.shopping_center26').html(phpData);
					}
				});	
			}else{
				$.ajax({
					type:"post",
					url:"{|U:'Index/MyCart/edit'}",
					data:{shuliang : shuliang,sid:sid},//请求数据
					dataType:'json',//数据类型
					success:function(phpData){
					}
				});	
			}
		});					
	})
</script>
<!--异步修改购物车商品结束-->
<!--单机加减号异步修改-->
<script type="text/javascript">
	$(function(){		
		$('a.add').click(function(){
			var sid = $(this).siblings('input.hiddenSid').val();//商品sid
			var i =$(this).parents('dd').find('input').val();
			i++;
			if(i<100){
				$(this).parents('dd').find('input.shuliang').val(i);
				var shuliang = $(this).parents('dd').find('input.shuliang').val();//点击增加以后再获得当前val值
				//获得单价的值
				var total = $(this).parents('dd').siblings('.danjia').html();
				//总价=单价*i
				$(this).parents('dd').siblings('.xiaoji').html(total*shuliang);			
				if($(this).parents('dd').siblings('.shopping_cart_tr11').find('input').attr("checked")){
					$.ajax({
						type:"post",
						url:"{{U('MyCart/edit')}}",
						data:{shuliang : shuliang,sid:sid},//请求数据
						dataType:'json',//数据类型
						success:function(phpData){
							$('.shopping_center26').html(phpData);
						}
					});	
				}else{
					$.ajax({
						type:"post",
						url:"{{U('MyCart/edit')}}",
						data:{shuliang : shuliang,sid:sid},//请求数据
						dataType:'json',//数据类型
						success:function(phpData){
						}
					});	
				}
			}
				
		})
		//点击减号单机事件
		$('a.mul').click(function(){
			var sid = $(this).siblings('input.hiddenSid').val();//商品sid
			var i =$(this).parents('dd').find('input.shuliang').val();		
			i--;
			if(i>0){
				$(this).parents('dd').find('input.shuliang').val(i);
				var shuliang = $(this).parents('dd').find('input.shuliang').val();//点击增加以后再获得当前val值
				//获得单价的值
				var total = $(this).parents('dd').siblings('.danjia').html();
				//总价=单价*i
				$(this).parents('dd').siblings('.xiaoji').html(total*shuliang);
				if($(this).parents('dd').siblings('.shopping_cart_tr11').find('input').attr("checked")){
					$.ajax({
						type:"post",
						url:"{{U('MyCart/edit')}}",
						data:{shuliang : shuliang,sid:sid},//请求数据
						dataType:'json',//数据类型
						success:function(phpData){
							$('.shopping_center26').html(phpData);
						}
					});	
				}else{
					$.ajax({
						type:"post",
						url:"{{U('MyCart/edit')}}",
						data:{shuliang : shuliang,sid:sid},//请求数据
						dataType:'json',//数据类型
						success:function(phpData){
						}
					});	
				}
			}
			
	    })
	})
</script>
<!--异步删除一个商品-->
<script type="text/javascript">
	$(function(){
		$('.delOneCart').click(function(){
			var sid = $(this).parents('dd').siblings('.shopping_cart_tr16').find('input.hiddenSid').val();//商品唯一sid
			var shuliang = $(this).parents('dd').siblings('.shopping_cart_tr16').find('input.shuliang').val();//商品数量
			var xiaoji = $(this).parents('dd').siblings('.xiaoji').html();//商品小计
			$(this).parents('.shopping_cart_tr').remove();//把当前div移除

			$.ajax({
						type:"post",
						url:"{{U('MyCart/delOneCart')}}",
						data:{shuliang : shuliang,sid:sid,xiaoji:xiaoji},//请求数据
						dataType:'json',//数据类型
						success:function(phpData){
							$('.shopping_center26').html(phpData);
						}
			});	
		})
	})
</script>

</head>

<body>	
<!--顶部导航-->
	<div id="top_nav">
		<div class="top_ad_center">
			<div class="num1">
				<a href="{{U('Index/index')}}">时尚商城</a>
			</div>

			<!--右侧-->
			<div class="top_ad_right">
				{{if value="isset($_SESSION['username'])"}}
					<div class="top_ad_right1">
						<span>您好，{{substr($_SESSION['username'],0,-7)}}</span>
						<a href="{{U('Public/out')}}" style="color: #666666;" class="out">退出登录</a>
					</div>
				{{else}}
					<div class="top_ad_right1">
						<a href="{{U('Public/login')}}">登陆</a>
						<a href="{{U('Public/reg')}}">注册</a>
					</div>
				{{endif}}
				<div class="top_ad_right2">
					{{if value="isset($_SESSION['username'])"}}
						<a href="{{U('MineYG/index')}}">我的优购</a>
					{{else}}
						<a href="{{U('Public/login')}}">我的优购</a>
					{{endif}}	
				</div>
				<div class="top_ad_right2">
					{{if value="isset($_SESSION['username'])"}}
						<a href="{{U('MineYG/order')}}">我的订单</a>
					{{else}}
						<a href="{{U('Public/login')}}">我的订单</a>
					{{endif}}
				</div>
			</div>
			<!--右侧结束-->
		</div>		
	</div>
<!--顶部导航结束-->
<!--logo区域-->
<div id="shop_logo">
	<div class="shop_logo1">
		<a href="{{U('Index/index')}}"><img src="{{TEMPLATE}}/images/shop_logo1.png" alt="" /></a>
	</div>
	<div class="shop_logo_right">
		<ul>
			<li class="current">我的购物车<em></em><i></i></li>
			<li>提交订单中心<em></em><i></i></li>
			<li>成功提交订单</li>
		</ul>
	</div>
</div>
<!--logo区域结束-->
<!--购物车详细内容区域-->
{{if value="isset($_SESSION['cart'])"}}
	<form action="{{U('OrderL/index')}}" method="post">
		<div class="shopping_center">
		<div class="shopping_center1">
			<table border="0" cellspacing="" cellpadding="">
				<colgroup>
					<col width="60"/>
					<col width="370"/>
					<col width="110"/>
					<col width="110"/>
					<col width="110"/>
					<col width="110"/>
					<col width="120"/>
				</colgroup>
				<thead>
					<tr>
						<th>						
							<i><input type="checkbox" name="CNYcheckAll" id="" value="" checked="checked"/><a href="javascript:;">全选</a></i>				
						</th>
						<th>商品名称</th>
						<th>颜色尺码</th>
						<th>单价</th>
						<th>数量</th>
						<th>小计（元）</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td colspan="7">
							{{foreach from="$goods" key="$k" value="$v"}}
							<div class="shopping_cart_tr ">
								<div class="shopping_cart_tr1"></div>
								<dl>
									<dd class="shopping_cart_tr11"><input type="checkbox" name="CNYcheck[]" value="" checked="checked" class="danxuan"/></dd>
									<dt class="shopping_cart_tr12"><a href=""><img src="{{$v['options']['pic']}}"/></a></dt>
									<dd class="shopping_cart_tr13"><a href="">{{$v['name']}}</a></dd>
									<dd class="shopping_cart_tr14">
										<div class="shopping_cart_tr141">
											<p>颜色: <em>{{$v['options']['color']}}</em></p>
										<p>尺码: <em>{{$v['options']['size']}}</em></p>
										</div>
									</dd>
									<dd class="shopping_cart_tr15 danjia">{{$v['price']}}</dd>
									<dd class="shopping_cart_tr16">
										<a href="javascript:;" class="mul">-</a>
										<input type="text" name="number[]" id="" value="{{$v['num']}}" class="shuliang"/>
										<a href="javascript:;" class="add">+</a>
										<input type="hidden" name="hiddenSid[]" id="" value="{{$k}}" class="hiddenSid"/>
									</dd>
									<dd class="shopping_cart_tr15 xiaoji">{{$v['total']}}</dd>
									<dd class="shopping_cart_tr15" style="margin-left: 8px;"><a href="javascript:;" class="delOneCart">删除</a></dd>
								</dl>	
								<div class="shopping_cart_tr1"></div>
							</div>
							{{endforeach}}
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div class="shopping_center2">
			<a href="{{U('Index/index')}}" class="shopping_center22">继续购物</a>
			<div class="shopping_center21"><a href="javascript:hd_modal_del();">清空购物车</a></div>
			<div class="shopping_center23">
				<strong class="shopping_center24">总计（不含运费）</strong>:
				<strong class="shopping_center25">¥</strong>
				<strong class="shopping_center26">{{$cart}}</strong>
				<input type="hidden" name="" id="" value="{{$cart}}" class="shopping_center27"/>
				<!--获取session中的用户名-->
					
				<!--获取session中的用户名-->
				{{if value="isset($_SESSION['username'])"}}
					<input type="submit" name="" class="qujiesuan" value="去结算"/>
					<input type="hidden" name="" class="sessionHidden" value="{{$_SESSION['username']}}"/>					
				{{else}}
					<a href="javascript:;" class="gopay">去结算</a>
				{{endif}}
			</div>	
		</div>
	</div>
	</form>
{{else}}
	<div style="text-align: center;padding: 50px 0;border: 1px solid #F1F1F1;width: 990px;margin: 0 auto;font-size: 18px;">
		您的购物车中暂无商品，赶快选择心爱的商品吧！
		<br /><br />
		<a href="{{U('Index/index')}}" style="color: #36C;font-size: 14px;text-decoration: underline;">回到首页</a>
	</div>
{{endif}}	
	
	



<!--购物车详细内容区域结束-->
<div class="shop_baozheng">
	<div class="shop_baozheng_right">
		<p>购物保障：<i>&nbsp;</i>100%正品<i>&nbsp;&nbsp;</i>10天退换货<i>&nbsp;&nbsp;</i>10天补差价</p>
		<p>帮助我们改进购物流程</p>
	</div>
	
</div>	
<!--底部-->
<div class="footer">
	<p>Copyright © 2011-2014 Yougou Technology Co., Ltd. 
		&nbsp;&nbsp;<a href="javascript:;">粤ICP备09070608号-4 </a>&nbsp;&nbsp;增值电信业务经营许可证：
		<a href="javascript:;">粤 B2-20090203</a> </p>
</div>	
<!--点击立即购买如果没有登陆弹出模态框-->
	<div class="buyLogin">
		<div class="buyLogin_center">
			<p>
				<span class="buyLogin_center1">您尚未登陆</span>
				<span class="buyLogin_center2">关闭<em>X</em></span>
			</p>
			<div class="buyLogin_center3">
				<ul>
					<li class="pop_tab1">登陆</li>
					<a href="{{U('Public/reg')}}">注册</a>
				</ul>
			</div>
			<div class="buyLogin_center4">
				<form action="" method="post">
					<div class="">
						<table border="0" cellspacing="0" cellpadding="">
							<colgroup>
								<col width="70"></col>
								<col></col>
							</colgroup>
							<tbody>
								<tr>
									<th>账     号：</th>
									<td><input type="text" name="username" id="" value="" placeholder="邮箱/用户名"/></td>
								</tr>
								<tr class="kongtr"></tr>
								<tr>
									<th>密    码：</th>
									<td><input type="password" name="password" id="" value="" placeholder=""/></td>
								</tr>
								<tr class="kongtr"></tr>
								<tr class="kongtr"></tr>
								<tr>
									<th></th>
									<td><input type="submit" name="pop_login" class="log_smt" value=""/></td>
								</tr>
							</tbody>
						</table>
					</div>
					
				</form>
			</div>
		</div>
	</div>

</body>

<!--全部上出模态框-->
<script type="text/javascript">
	function hd_modal_del() {
        hd_modal({
            width: 400,//宽度
            height: 150,//高度
            title: '确认把购物车清空吗？',//标题
            content: '',//提示信息
            button: true,//显示按钮
            button_success: "确定",//确定按钮文字
            button_cancel: "取消",//关闭按钮文字
            timeout: 0,//自动关闭时间 0：不自动关闭
            shade: false,//背景遮罩
            shadeOpacity: 0.4,//背景透明度
            success: function () {
            	//点击确定后的事件
				location.href ="{{U('MyCart/delAllCart')}}";
            },
            cancel: function () {//点击关闭后的事件
				
            }
        });
    }
</script>
</html>
